using System.Collections;

using System.Diagnostics;

using CStock;
using System;


using NUnit.Framework;

using CIndicators;
using TestCases.StockData;
using TicTacTec.TA.Library;
namespace TestCases.Indicators
{
	
	[TestFixture] 
	public class TALIB_Test
	{
		IIndicator indicator;
		IDataClass dataClass;
		//IProgramContext programContext;
		[SetUp] 
		public void Init() 
		{
			
			//new share, with some sample data
			DataClassTest dct = new DataClassTest();

            dataClass = dct.DataClassFactory.StockObjectBase as IDataClass;
	
		}
		[Test] 
		
		
		public void EvaluateMA5() 
		{
            indicator = new CIndicators.MovingAverageExponential();
			indicator.Interval = 5;
			indicator.Parent = dataClass;
            indicator = IndEvaluator.Indicator_XMLOrEvaluate(indicator);

			//indicator.Evaluate(); //saves the indicator !
            
		
		}
        [Test] 
        public void EvaluateTAInd()
        {
            double[] input = new double[10];
            double[] outputSMA = new double[10];
            double[] outputWMA = new double[10];
            double[] outputEMA = new double[10];

            int outBegIdx;
            int outNbElement;

            // Fill up the input with dummy data. 
            //dataClass.QuoteCollection.Clear();

            IListQuotes quColl = new ListQuotes();
            int iNumberOfItems = 10;
            for (int i = 0; i < iNumberOfItems; i++)
            {
                IQuote qu = new Quote();
                qu.CLOSEc = (double)i;
                input[i] = (double)i;
                quColl.Add(qu);
            }
            //dataClass.QuoteCollection 
            dataClass.SetSeriesFromQuoteCollection(quColl);
            indicator = new CIndicators.MovingAverageWeighted();
            
            indicator.Interval = 4;
            indicator.Parent = dataClass;
            indicator = IndEvaluator.Indicator_XMLOrEvaluate(indicator); //saves the indicator !

            //----------------
            //int iBeginIndex = 4;
            int iStopIndex = iNumberOfItems -1 ;

            //Core.Wma(0, iStopIndex, input, indicator.Interval, out outBegIdx, out outNbElement, output);
            Core.Sma(0, iStopIndex, indicator.CloseArr, indicator.Interval, out outBegIdx, out outNbElement, outputSMA);
            Core.Wma(0, iStopIndex, indicator.CloseArr, indicator.Interval, out outBegIdx, out outNbElement, outputWMA);
            Core.Ema(0, iStopIndex, indicator.CloseArr, indicator.Interval, out outBegIdx, out outNbElement, outputEMA);
            for (int i = indicator.Interval; i < iNumberOfItems; i++)
            {

                Debug.WriteLine("IND " + outputWMA[i - indicator.Interval].ToString() + " ; " + outputSMA[i - indicator.Interval].ToString() + " ; " + outputEMA[i - indicator.Interval].ToString() + " ; ");
                             
                Debug.WriteLine("WMA " + indicator.ValuesFloat[i].ToString());
                
            }
           
           

            //Timeseries ts_r1 = new Timeseries(10);

            //// Add a sequence 0,1,2,3,4,5,6,7,8,9
            //ts_r1.Add.Sequence(delegate(int n) { return n; });


        }


    }
}